Public Partial Class Forums
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Private Sub dlstForums_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles dlstForums.ItemDataBound
        Dim latestPost As KDESolutions.Providers.Forums.DataTypes.PostDetails
        latestPost = KDESolutions.Providers.Forums.ForumService.GetLatestPost(CType(e.Item.DataItem, KDESolutions.Providers.Forums.DataTypes.ForumDetails).ID)
        Dim ThreadCount As Integer
        ThreadCount = CInt(KDESolutions.Providers.Forums.ForumService.GetThreadCount(CType(e.Item.DataItem, KDESolutions.Providers.Forums.DataTypes.ForumDetails).ID))
        CType(e.Item.FindControl("lblThreadCount"), Label).Text = ThreadCount
        CType(e.Item.FindControl("lnkLatestPost"), LinkButton).Text = latestPost.Title
        CType(e.Item.FindControl("lnkLatestPost"), LinkButton).PostBackUrl = "~/ShowThread.aspx?ForumID=" & CType(e.Item.DataItem, KDESolutions.Providers.Forums.DataTypes.ForumDetails).ID
        CType(e.Item.FindControl("lblLatestPostBy"), Label).Text = latestPost.AddedBy
        If latestPost.AddedDate.Date = Now.Date Then
            CType(e.Item.FindControl("lblLatestPostDate"), Label).Text = "Today at " & latestPost.AddedDate.TimeOfDay.ToString
        Else
            CType(e.Item.FindControl("lblLatestPostDate"), Label).Text = latestPost.AddedDate.ToShortDateString
        End If

    End Sub
End Class